<?php
namespace Components\Account\User\Wallet;

class Validation extends \Phalcon\Validation {
	public function execute($data) {
		$result = [];
		$validationMessages = $this -> validate($data);
		if($validationMessages -> valid()) {
			return ['code'=>-1,'message'=>$validationMessages[0]->getMessage()];
		} else {
			return ['code'=>0,'data'=>$data];
		}
	}

	public function addType() {
		return $this -> rules('type',[
			new \Phalcon\Validation\Validator\PresenceOf(),
			new \Phalcon\Validation\Validator\InclusionIn([
				'domain' => [1, 2, 3, 4, 5]
			])
		]);
	}

	public function addAccount() {
		return $this -> rules('account',[
			new \Phalcon\Validation\Validator\PresenceOf(),
			new \Phalcon\Validation\Validator\StringLength([
				'min' => 6
			])
		]);
	}

	public function addAmount() {
		return $this -> rules('amount',[
			new \Phalcon\Validation\Validator\PresenceOf()
		]);
	}

	public function addActive() {
		return $this -> rules('active',[
			new \Phalcon\Validation\Validator\PresenceOf(),
			new \Phalcon\Validation\Validator\InclusionIn([
				'domain' => [1, 2]
			])
		]);
	}
}
